package com.diudiutechnology.www.yadiudiu.yadiudiu.house.MyAdapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.diudiutechnology.www.yadiudiu.yadiudiu.model.BuyACarFragmentModel;
import com.diudiutechnology.www.yadiudiu.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/9/1.
 * 买房
 */

public class BuyHouseAdapter extends BaseAdapter {

    private Context mContext;

    List<BuyACarFragmentModel> model= new ArrayList<>();
    List<Integer> listint=new ArrayList<>();
    public BuyHouseAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return model.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    public void addItem( List<BuyACarFragmentModel> model,List<Integer> listint){
        this.listint=listint;
        this.model=model;
        notifyDataSetChanged();
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.item_buy_house, null);

            holder.itme_type = (LinearLayout) convertView
                    .findViewById(R.id.itme_type);

            holder.line = (TextView) convertView
                    .findViewById(R.id.line);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        if (listint.get(position)==position){
            holder.itme_type.setVisibility(View.VISIBLE);
        }else {
            holder.itme_type.setVisibility(View.GONE);
        }
        if ((model.size()-1)==position){
            holder.line.setVisibility(View.VISIBLE);
        }else {
            holder.line.setVisibility(View.GONE);
        }
        return convertView;
    }

    class ViewHolder {

        LinearLayout itme_type; //类型


        TextView line;
    }
}

